<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    /* // 自定义错误
    // Error
    function fn(num){
      if(typeof num !== 'number') {
        // 报错
        var err = new Error('参数必须是number');
        // console.log(err);
        throw(err);
      }
    }
    // 函数调用时 一定要传数字
    fn('111')
    console.log(222); */

    // try...catch 捕获 错误 用于 代码兼容性问题

    /* try{
      console.log(a);
    }catch(err){
      console.log(err);
      console.log(222);
    }
    
    console.log(333); */

    /* if(e.stopPropagation) {
      e.stopPropagation()
    }else{
      e.cancelBubble = true
    } */
    try{
      e.stopPropagation()
    }catch(err) {
      e.cancelBubble = true
    }
  </script>
</body>
</html>